import Layout from '@/pages/Layout';
import Login from '@/pages/Login';
import { AuthRoute } from '@/components/AuthRoute';
// import Publish from '@/pages/Publish'
// import Homes from '@/pages/Homes'
// import Article from '@/pages/Article'
import {lazy, Suspense} from 'react'

// 配置路由
import { createBrowserRouter } from 'react-router-dom';
// lazy函数对组件进行导入
const Homes = lazy(() => import('@/pages/Homes'));
const Article = lazy(() => import('@/pages/Article'));
const Publish = lazy(() => import('@/pages/Publish'));



const router = createBrowserRouter ([
    {
        path: '/',
        element: (
        <AuthRoute><Layout /></AuthRoute>
        ),
        children: [
            {   
                index:true,
                path:'/home',
                element: <Suspense fallback={'加载中'}><Homes /></Suspense>
            },
            {   
                path:'/article',
                element:  <Suspense fallback={'加载中'}><Article /></Suspense>
            },
            {
                path:'/publish',
                element:  <Suspense fallback={'加载中'}><Publish /></Suspense>
            }
        ]
    },
    {
        path:'/login',
        element: <Login />
    }
])

export default router;

